<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css">
    <script type="text/javascript" src="__STATIC__/x-admin/js/xadmin.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">
</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="#">系统设置</a>
        <a href="#">系统设置</a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div style="height: 30px"></div>
<div style="width: 500px;font-size: 10px">
    <form class="layui-form" action="" onsubmit="return false" id = 'systemInfo'>
        <input type="hidden" value="{$systemInfo.id}" name="system_id">
        <div class="layui-form-item">
            <label class="layui-form-label">系统名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" id="name" value="{$systemInfo.name}"  placeholder="系统名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">系统描述</label>
            <div class="layui-input-block">
                <textarea name="describe" id="describe" placeholder="系统描述" class="layui-textarea">{$systemInfo.describe}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">系统开关</label>
            <div class="layui-input-block">
                <input type="checkbox" {if $systemInfo.is_open == 1} checked {/if} name="is_open" title="系统开关" lay-skin="primary" >
                <input type="checkbox" {if $systemInfo.is_register == 1} checked {/if}  name="is_register" title="用户注册开关" lay-skin="primary" >
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" id="save">立即保存</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script>
    //表单初始化
    layui.use('form', function(){
        var form = layui.form;
        layer = layui.layer;
    });
</script>
<script>
    $("#save").click(function(){
        if(!$("#name").val()){
            layer.msg('系统名称不能为空',{icon:5,time:2000});
            return;
        }
        if(!$("#describe").val()){
            layer.msg('系统描述不能为空',{icon:5,time:2000});
        }
        $.ajax({
            url:"{:url('/system/preservation')}",
            type:"post",
            data:$("#systemInfo").serialize(),
            dataType:"json",
            success:function(res){
                if(res.code){
                    layer.msg(res.msg,{icon:1,time:2000},function(){
                        window.location.reload();
                    });
                    return;
                }else{
                    layer.msg(res.msg,{icon:5,time:2000});
                    return;
                }
            }
        });
    });
</script>
</body>
</html>